//
//  socket.h
//  touc
//
//  Created by z on 2020/6/26.
//  Copyright © 2020 z. All rights reserved.
//

#ifndef socket_h
#define socket_h
#include <stdbool.h>
#include <stdio.h>

void structPack(int ty,int64_t a, unsigned char* buf);
void structPack_d(int ty,double a, unsigned char* buf);
int64_t structUnpack(int ty,const unsigned char* buf);
double structUnpack_d(int ty,const unsigned char* buf);
uint16_t getPeerAdd(int so,uint32_t* ip);
void setNonblock(int fd);
void setDoblock(int fd);
int readtcp(int so,unsigned char* buf,int l );
int writetcp(int so,unsigned char* buf,int l );
int makeSock(int type);
int bindso(int connSock,uint32_t ip,uint16_t port);
int connectso(int so,uint32_t ip,uint16_t port);
int listenso(int so,int num);
int acceptso_add(int so,uint32_t* ip,uint16_t* port);
int acceptso(int so);
uint16_t getAdd(int so,uint32_t* ip);
void writeudp(int so, unsigned char* buf,int l,uint32_t ip,uint16_t port);
int readudp_add(int so,unsigned char* buf,int l,uint32_t* ip,uint16_t* port);
int readudp(int so,unsigned char* buf,int l);
void* openPoll(int n);
void closePoll(void * p);
void registerPoll(void *p,int pollNum,int fd,int e);
bool getPoll(void *p,int lo,int fd,int e);
void getPoll2(void *p,int lo,int *fd,int *e);
int doPoll(void *p,int pollNum,int tt);
void setNoSig(int so);
void closeSock(int so);
#endif /* socket_h */
